//============== Networked: SA - http://code.google.com/p/n-sa/ ==============
//
// File: CSAPhysical.cpp
// Project: Client
// Developers: bpeterson
// License: See LICENSE in root directory
//
//============================================================================

#include <StdInc.h>

extern CClient * g_pClient;

CSAPhysical::CSAPhysical()
{

}

CSAPhysical::~CSAPhysical()
{

}

SAPhysical * CSAPhysical::GetPhysical()
{
        return (SAPhysical *)GetEntity();
}

void CSAPhysical::GetMoveSpeed(CVector * vecMoveSpeed)
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();

        if(pPhysical)
        {
                DWORD dwFunc = FUNC_GetMoveSpeed;
                _asm
                {
					push vecMoveSpeed
                    mov ecx, pPhysical
                    call dwFunc
                }
        }
}

void CSAPhysical::SetMoveSpeed(CVector * vecMoveSpeed)
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();

        if(pPhysical)
        {
                DWORD dwFunc = FUNC_GetMoveSpeed;
				DWORD dwReturn = 0;
                _asm
                {
					mov	ecx, pPhysical
					call dwFunc
					mov dwReturn, eax
                }
        }
		memcpy((void*)dwReturn, vecMoveSpeed, sizeof(CVector));
}

void CSAPhysical::GetTurnSpeed(CVector * vecTurnSpeed)
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();
        
        if(pPhysical)
        {
                DWORD dwFunc = FUNC_GetTurnSpeed;
                _asm
                {
					push vecTurnSpeed
                    mov ecx, pPhysical
                    call dwFunc
                }
        }
}

void CSAPhysical::SetTurnSpeed(CVector * vecTurnSpeed)
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();

        if(pPhysical)
        {
                DWORD dwFunc = (g_pClient->GetBaseAddress() + FUNC_SetTurnSpeed);
				DWORD dwReturn = 0;
                _asm
                {
					mov ecx, pPhysical
					call dwFunc
					mov dwReturn, eax
                }
        }
		memcpy((void *)dwReturn, vecTurnSpeed, sizeof(CVector));
}

SAEntity * CSAPhysical::GetLastDamageEntity()
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();

        if(pPhysical)
                return pPhysical->m_pLastDamageEntity;

        return NULL;
}

void CSAPhysical::SetLastDamageEntity(SAEntity * pLastDamageEntity)
{
        SAPhysical * pPhysical = (SAPhysical *)GetEntity();

        if(pPhysical)
                pPhysical->m_pLastDamageEntity = pLastDamageEntity;
}

// EOF